import request from '@/utils/request'

export const login = (params) => {
  return request({
    method: 'POST',
    url: '/users/login',
    data: params,
  })
}

export const getUserList = (data) => {
  return request({
    method: 'GET',
    url: '/users/list',
    data,
  })
}
export const getUserAllList = () => {
  return request({
    method: 'GET',
    url: '/users/all/list',
    // url: '/users/list',
  })
}

export const userSubmit = (data) => {
  return request({
    method: 'POST',
    url: '/users/operate',
    data,
  })
}

export const deleteUser = (data) => {
  return request({
    method: 'POST',
    url: '/users/delete',
    data,
  })
}

export const getPermissionList = () => {
  return request({
    method: 'GET',
    url: '/users/getPermissionList',
  })
}

// --------------------------------------------------------------

export const menuSubmit = (data) => {
  if (data.type !== 'delete') {
    data.type = data._id ? 'edit' : 'add'
  }
  return request({
    method: 'POST',
    url: '/menu/operate',
    data,
  })
}

export const menuDel = (_id) => menuSubmit({ _id, type: 'delete' })

export const getNoticeCount = () => {
  return request({
    method: 'GET',
    url: '/leave/count'
  })
}

export const getMenuList = (data) => {
  return request({
    method: 'GET',
    url: '/menu/list',
    data,
  })
}

// /roles/allList
export const getRoleList = () => {
  return request({
    method: 'GET',
    url: '/roles/allList',
    // mock: true,
  })
}

export const updatePermission = (data) => {
  return request({
    method: 'POST',
    url: '/roles/update/permission',
    data,
    // mock: true,
  })
}

export const getDeptList = (data) => {
  return request({
    method: 'GET',
    url: '/depts/list',
    data,
    // mock: true,
  })
}
export const deptSubmit = (data) => {
  return request({
    method: 'POST',
    url: '/depts/operate',
    data,
    // mock: true,
  })
}


export const getRoleTableList = (params) => {
  return request({
    method: 'GET',
    url: '/roles/list',
    data: params,
  })
}

export const roleSubmit = (data) => {
  return request({
    method: 'POST',
    url: '/roles/operate',
    data,
    // mock: true,
  })
}

export const getApplyList = (params) => {
  return request({
    url: '/leave/list',
    data: params,
    method: 'GET',
    mock: false
  })
}

export const leaveOperate = (params) => {
  return request({
    url: '/leave/operate',
    data: params,
    method: 'POST',
    mock: false
  })
}

export default {}
